from typing import List
class Solution:
    # 等差数组至少要3个元素
    # dp[i]表示以A[i]结尾的等差数列的个数
    # dp[i] = dp[i-1]+1
    def numberOfArithmeticSlices(self, A: List[int]) -> int:
        n = len(A)
        if n < 3:#判断初始化长度
            return 0
        dp = [0 for _ in range(n)]#数量集初始化
        # sum_ans = 0#计数器
        for i in range(2,n):
            print(A[i-2],A[i-1],A[i])
            if A[i]-A[i-1] == A[i-1]-A[i-2]:#判断三个是否为等差数列
                dp[i] = dp[i-1] + 1#如果是那么对应的计数器加一
                # sum_ans += dp[i]#总的计数器加一
        print(dp)
        # return sum_ans
        return(sum(dp))

A = [1, 2, 3, 4, 5, 6]
a=Solution()
print(a.numberOfArithmeticSlices(A))